package com.yanqu.road.entity.beautyescort.rank;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.union.UnionBaseInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@FieldTypeAnnotation(tableName = "t_u_escort_week_union_value")
public class EscortWeekUnionValue extends DataObject {

    @FieldTypeAnnotation(desc = "周id", update = true, select = true)
    private int weekId;

    @FieldTypeAnnotation(desc = "商会uid", update = true)
    private String unionUid = "";

    @FieldTypeAnnotation(desc = "商会基础信息")
    private UnionBaseInfo unionBaseInfo = new UnionBaseInfo();

    @FieldTypeAnnotation(desc = "商会成员")
    private List<Long> userList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "值")
    private long value;

    public int getWeekId() {
        return weekId;
    }

    public void setWeekId(int weekId) {
        if(this.weekId != weekId) {
            this.weekId = weekId;
            setUpdateOption();
        }
    }

    public String getUnionUid() {
        return unionUid;
    }

    public void setUnionUid(String unionUid) {
        if(!Objects.equals(this.unionUid, unionUid)) {
            this.unionUid = unionUid;
            setUpdateOption();
        }
    }

    public UnionBaseInfo getUnionBaseInfo() {
        return unionBaseInfo;
    }

    public void setUnionBaseInfo(UnionBaseInfo unionBaseInfo) {
        if(this.unionBaseInfo != unionBaseInfo) {
            this.unionBaseInfo = unionBaseInfo;
            setUpdateOption();
        }
    }

    public List<Long> getUserList() {
        return userList;
    }

    public void setUserList(List<Long> userList) {
        if(this.userList != userList) {
            this.userList = userList;
            setUpdateOption();
        }
    }

    public long getValue() {
        return value;
    }

    public void setValue(long value) {
        if(this.value != value) {
            this.value = value;
            setUpdateOption();
        }
    }


    public boolean hasMemberUserId(long userId){
        return userList.contains(userId);
    }

    public void addMemberUserId(long userId){
        if(!hasMemberUserId(userId)){
            userList.add(userId);
            setUpdateOption();
        }
    }

    public void removeMemberUserId(long userId){
        if(hasMemberUserId(userId)){
            userList.remove(userId);
            setUpdateOption();
        }
    }

}
